<template>
    <div v-if="access_token" class="header">
        <router-link class="header_title" to="/">学员信息管理系统</router-link>
        <button
            class="header_Administration"
            style="background-color: rgb(68, 183, 250, 0)"
            @click="btns">
            游客<i class="el-icon-caret-bottom"></i>
        </button>
        <router-link class="uls" v-if="asd" to="/zhanghaoxinxi">账号信息</router-link>
        <div @click="tui" class="uls1" v-if="asd"> 退出 </div>
    </div>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: true,
      asd: false,
      access_token:false,
      dynamicTags:[{tile:'系统首页',path:'/'}],
    };
  },
  methods: {
    opens() {
      this.isCollapse = !this.isCollapse;
      console.log(window.getComputedStyle(this.$refs.foot_foot_w).width);
      if (this.isCollapse == false) {
        console.log(11111);
        this.$refs.foot_foot_w.style.width = 85.5 + "%";
      } else if (this.isCollapse == true) {
        console.log(22222);
        this.$refs.foot_foot_w.style.width = 95.5 + "%";
      }
    },
    publics(tile,path){
      if(this.$route.path == path){return}
      this.$router.push(path);
      for(let i=0;i<this.dynamicTags.length;i++){ 
        if(this.dynamicTags[i].path==path){
          return;
        }
      }
      this.dynamicTags.push({
        path,
        tile
      })
      sessionStorage.setItem('dynamicTags',JSON.stringify(this.dynamicTags));
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    btns(){
      this.asd = !this.asd;
    },
    // 其他页面标题跳转
    Y_qitabiaoti(tag){
      if(this.$route.path != tag){
        this.$router.push(tag);
      }
    },
    biaoti(tag){
      console.log(tag);
      for(let i=1;i<this.dynamicTags.length;i++){
        if(this.dynamicTags[i].path == tag){
          this.dynamicTags.splice(i, 1);
          console.log(this.dynamicTags );
          sessionStorage.setItem('dynamicTags',JSON.stringify(this.dynamicTags));
          if(this.$route.path!='/'){
            this.$router.push(this.dynamicTags[i-1]);
          }
        }
      }
    },
    tui(){
      localStorage.clear();
      this.$router.push("/login");
      setTimeout(()=>{
        location.reload();
      },10)
    }
  },
  created(){
    this.access_token = localStorage.getItem('access_token');
    if(sessionStorage.getItem('dynamicTags')){
      this.dynamicTags = JSON.parse(sessionStorage.getItem('dynamicTags'));
    }
  }
};
</script>

<style scoped>
.header {
  width: 100%;
  height: 50px;
  background: -webkit-linear-gradient( 
    left,
    rgb(18, 128, 188),
    rgb(97, 183, 250),
    rgb(68, 183, 250)
  );
  line-height: 50px;
}
.header_title {
  color: white;
  margin-left: 25px;
  float: left;
  font-weight: bolder;
  font-size: 24px;
  font-family: fangsong;
  text-decoration: none;
}
.header_Administration {
  width: 100px;
  height: 50px;
  margin-right: 25px;
  float: right;
  color: white;
  border: 0;
}
.uls {
  width: 100px;
  background-color: rgb(215, 225, 226);
  position: absolute;
  right: 20px;
  top: 50px;
  text-align: center;
  text-decoration: none;
}
.uls1{
  width: 100px;
  background-color: rgb(215, 225, 226);
  position: absolute;
  right: 20px;
  top: 100px;
  text-align: center;
  text-decoration: none;
}   
</style>